package com.motong.gongdan.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.motong.gongdan.entity.WorkOrder;
import com.motong.gongdan.vo.ExcelModel.WorkOrderDetailPrintModel;
import com.motong.gongdan.vo.H5Resp.H5DataBoardResp;
import com.motong.gongdan.vo.H5Resp.H5ProductFinishNumResp;
import com.motong.gongdan.vo.H5Vo.Dashboard.query.GetAllQuery;
import com.motong.gongdan.vo.H5Vo.Dashboard.query.H5OrderListQuery;
import com.motong.gongdan.vo.H5Vo.Dashboard.query.OrderNumDetailQuery;
import com.motong.gongdan.vo.H5Vo.Dashboard.vo.FinishNumStatisticsVo;
import com.motong.gongdan.vo.H5Vo.Dashboard.vo.H5OrderListVo;
import com.motong.gongdan.vo.H5Vo.Dashboard.vo.WorkOrderStatisticsVo;
import com.motong.gongdan.vo.H5Vo.common.GroupCountVo;
import com.motong.gongdan.vo.H5Vo.workOrder.vo.WorkListMergedConditionVo;
import com.motong.gongdan.vo.resp.*;
import com.motong.gongdan.vo.system.dataController.query.WorkOrderOverviewQuery;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface WorkOrderMapper extends BaseMapper<WorkOrder> {

    IPage<WorkOrderResp> selectForList(IPage<WorkOrderResp> page, @Param("code") String code, @Param("productCode") String productCode, @Param("productName") String productName, @Param("productSpecification") String productSpecification,
                                       @Param("unit") String unit, @Param("comment") String comment, @Param("planedNumberDown") BigDecimal planedNumberDown,
                                       @Param("planedNumberUp") BigDecimal planedNumberUp, @Param("actualNumberDown") BigDecimal actualNumberDown, @Param("actualNumberUp") BigDecimal actualNumberUp,
                                       @Param("goodProductNumberDown") BigDecimal goodProductNumberDown, @Param("goodProductNumberUp") BigDecimal goodProductNumberUp,
                                       @Param("badProductNumberDown") BigDecimal badProductNumberDown, @Param("badProductNumberUp") BigDecimal badProductNumberUp,
                                       @Param("startTimeStart") Date startTimeStart, @Param("startTimeEnd") Date startTimeEnd, @Param("endTimeStart") Date endTimeStart,
                                       @Param("endTimeEnd") Date endTimeEnd, @Param("actualStartTimeStart") Date actualStartTimeStart, @Param("actualStartTimeEnd") Date actualStartTimeEnd,
                                       @Param("actualEndTimeStart") Date actualEndTimeStart, @Param("actualEndTimeEnd") Date actualEndTimeEnd, @Param("state") List<Integer> state, @Param("ids") List<Integer> ids,
                                       @Param("sortInfoStr") String sortInfoStr);

    IPage<WorkOrderResp> selectForListH5(IPage<WorkOrderResp> page, @Param(Constants.WRAPPER) Wrapper<WorkOrderResp> wrapper, @Param("order") String order, @Param("orderType") String orderType, @Param("code") String code, @Param("productCode") String productCode, @Param("productName") String productName, @Param("productSpecification") String productSpecification,
                                         @Param("unit") String unit, @Param("comment") String comment, @Param("planedNumberDown") BigDecimal planedNumberDown,
                                         @Param("planedNumberUp") BigDecimal planedNumberUp, @Param("actualNumberDown") BigDecimal actualNumberDown, @Param("actualNumberUp") BigDecimal actualNumberUp,
                                         @Param("goodProductNumberDown") BigDecimal goodProductNumberDown, @Param("goodProductNumberUp") BigDecimal goodProductNumberUp,
                                         @Param("badProductNumberDown") BigDecimal badProductNumberDown, @Param("badProductNumberUp") BigDecimal badProductNumberUp,
                                         @Param("startTimeStart") Date startTimeStart, @Param("startTimeEnd") Date startTimeEnd, @Param("endTimeStart") Date endTimeStart,
                                         @Param("endTimeEnd") Date endTimeEnd, @Param("actualStartTimeStart") Date actualStartTimeStart, @Param("actualStartTimeEnd") Date actualStartTimeEnd,
                                         @Param("actualEndTimeStart") Date actualEndTimeStart, @Param("actualEndTimeEnd") Date actualEndTimeEnd, @Param("state") List<Integer> state, @Param("ids") List<Integer> ids);

    List<WorkOrderResp> selectForList();

    IPage<WipResp> getArticlesBeingProcessedData(Page page, @Param(Constants.WRAPPER) Wrapper<WipResp> wrapper);

    IPage<HomeScheduleResp> getHomeScheduleData(Page page, @Param("type") Integer type);

    List<YieldTimeResp> getDataByTime(@Param("startTime") String startTime, @Param("endTime") String endTime);

    IPage<WorkOrderResp> getH5WorkOrderList(Page page, @Param(Constants.WRAPPER) Wrapper<WorkOrderResp> wrapper, @Param("order") String order, @Param("orderType") String orderType);

    List<WorkOrderResp> getH5WorkOrderListList(@Param(Constants.WRAPPER) Wrapper<WorkOrderResp> wrapper, @Param("order") String order, @Param("orderType") String orderType);


    WorkOrderDetailResp getWorkOrder(@Param(Constants.WRAPPER) Wrapper<WorkOrderDetailResp> wrapper);


    WorkOrderDetailPrintModel getModelData(@Param("id") Integer id);

    List<WorkOrder> getWorkOrderByProcessId(@Param("processId") Integer processId, @Param("search") String search);

    List<WorkOrder> getWorkOrderByProcessIdAndCondition(@Param("screen") String screen, @Param("processId") Integer processId);

    List<Integer> getTimeingWo(@Param("startTime") String startTime, @Param("endTime") String endTime);

    H5ProductFinishNumResp getProductNum(@Param("productId") Integer productId);

    H5DataBoardResp getDataBoard(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<Integer> getDataBoardProductId(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("screen") String screen);

    StatisticsNumResp getEventStatistics(@Param("func") String func, @Param("list") List<Integer> list);

    /**
     * 根据id获取导出数据
     *
     * @param id 工单id
     */
    Map<String, Object> getExportData(@Param("id") Integer id);

    /**
     * 根据id获取任务相关信息
     *
     * @param id 工单id
     */
    List<Map<String, Object>> getExportProcessList(@Param("id") Integer id);

    /**
     * 计算工时
     *
     * @param workOrderCode 工单编码
     */
    Long completeWorkReport(@Param("workOrderCode") String workOrderCode);

    /**
     * 获取工单统计数据
     *
     * @param param 请求参数
     */
    WorkOrderStatisticsVo workOrderStatistics(@Param("param") GetAllQuery param);

    /**
     * 获取完成量统计数据
     *
     * @param param 请求参数
     */
    Page<FinishNumStatisticsVo> finishNumStatistic(Page<WorkOrder> page, @Param("param") OrderNumDetailQuery param);

    /**
     * h5获取工单列表
     *
     * @param param 请求参数
     */
    Page<H5OrderListVo> h5OrderList(Page<WorkOrder> page, @Param("param") H5OrderListQuery param);

    /**
     * h5获取工单列表状态数量
     */
    List<Map<String, Object>> h5OrderListCountByStatus(@Param("param") H5OrderListQuery param);


    /**
     * 获取按类型分类数据
     *
     * @param searchCondition 查询条件
     * @return 分类数量数据
     */
    List<GroupCountVo> getTypeCountMap(@Param("param") WorkListMergedConditionVo searchCondition, @Param("groupColumn") String groupColumn);

    /**
     * 看板获取工单概览
     *
     * @param workOrderOverviewQuery 查询条件
     * @return WorkOrderResp 工单数据
     */
    Page<WorkOrderResp> getWorkOrderOverview(Page<WorkOrder> page, @Param("param") WorkOrderOverviewQuery workOrderOverviewQuery);


    /**
     * h5获取工单列表
     */
    IPage<WorkOrderResp> h5GetWorkOrder(Page<WorkOrder> page, @Param("param") WorkListMergedConditionVo param);

    long getGroupCountVo(@Param("query") WorkListMergedConditionVo query);

    /**
     * pc获取工单列表
     */
    IPage<WorkOrderResp> getList(Page<WorkOrder> page, @Param("param") WorkListMergedConditionVo param, @Param("sortInfoStr") String sortInfoStr);
}